import { Controller, Get, Post, Body } from '@nestjs/common';
import { UserRoleService } from '../services/users-role.service';
import { responseWrapper } from 'src/utils';
import { ObjectType, CommonResponse } from 'src/types/index';

@Controller('user_role')
export class UserRoleController {
  constructor(private readonly userRoleService: UserRoleService) {}

  @Post()
  async assignRole(@Body() data: ObjectType): Promise<CommonResponse> {
    try {
      const res = await this.userRoleService.assignRole(data);
      return responseWrapper(res);
    } catch (error) {
      return responseWrapper(error, true);
    }
  }
}
